<template>
	<view class="page">

		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
			<!-- :down="downOption" :up="upOption" -->

			<uni-list>

				<view class="item" v-for="(item, index) in listdata" :key="index">

					<view style="display: inline-flex; justify-content: flex-end;">

						<text class="title">费用减免记录</text>

						<view class="btn-detail" style="color: #FFC500;background-color:#FFFFFF;white-space: nowrap;">{{item.processingStateStr}}</view>
					</view>

					<u-line color="#efefef" :customStyle="{'margin-bottom': '30rpx','display': 'block',}"></u-line>

					<view class="text-line">
						<text class="text-name">品牌/车系/车型:</text>
						<text class="text-value">{{item.brandSeriesModel|filterNull}}</text>
					</view>

					<view class="text-line">
						<text class="text-name">{{2==rentType?'整备费':5==rentType?'首付款/元/台':
							1==rentType||3==rentType||4==rentType?'保证金/元/台':'总单价'}}:</text>
						<text class="text-value">￥{{2==rentType?item.servicingFee:5==rentType?item.downPayment:
							1==rentType||3==rentType||4==rentType?item.deposit:item.totalPrice}}</text>
					</view>

					<view class="text-line" v-if="1==rentType||2==rentType||3==rentType||4==rentType||5==rentType">
						<text class="text-name">月租/元/台:</text>
						<text class="text-value">￥{{item.monthlyRent|filterNull}}</text>
					</view>

					<view class="text-line">
						<text class="text-name">减免金额/元:</text>
						<text class="text-value">￥{{item.creditAmount|filterNull}}</text>
					</view>
					
					<view class="text-line">
						<text class="text-name">减免原因:</text>
						<text class="text-value">{{item.reliefReason|filterNull}}</text>
					</view>
					
					<view class="text-line">
						<text class="text-name">上次凭证:</text>
						<text class="text-value" v-if="item.accessoryList.length<=0">--</text>
					</view>
					
					<view style="margin: 0 20rpx 20rpx 20rpx;" v-if="item.accessoryList.length>0">
						<u-album :urls="item.accessoryList"></u-album>
					</view>
					
					<view class="text-line">
						<text class="text-name">申请时间:</text>
						<text class="text-value">{{item.applyTime|filterNull}}</text>
					</view>
					
					<view class="text-line">
						<text class="text-name">处理意见:</text>
						<text class="text-value">{{item.processingOpinion|filterNull}}</text>
					</view>
					
					<view class="text-line">
						<text class="text-name">处理时间:</text>
						<text class="text-value">{{item.processingTime|filterNull}}</text>
					</view>



				</view>
			</uni-list>

		</mescroll-body>


	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";

	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				page: 1,
				listdata: [],
				orderCarNo:'',
				rentType:''
			}
		},

		methods: {
			getData() {
				
				let that = this

				this.$u.api.cosreliefRecord({
						orderCarNo: this.orderCarNo,
						pageNo: this.page,
					}).then(
						res => {


							if (this.page == 1) {
								this.listdata = [];
							}
							this.listdata = this.listdata.concat(res);
							
							if(!uni.$u.test.isEmpty(that.listdata)){
								that.listdata = that.listdata.map(item=>{
									item.accessoryList = item.accessoryList.map(sitem=>{
										return that.baseImgUrl()+sitem
									})
									
									return item
								})
							}
              this.mescroll.endSuccess(res.length);
						}
					)
					.catch(() => {
						this.mescroll.endErr();
					})
			},

			upCallback(page) {
				console.log("触发了上拉加载" + page);

				this.page = page.num;
				this.getData();
			},

		},
		onLoad(op) {
			this.orderCarNo = 'null'!=op.orderCarNo?op.orderCarNo:''
			this.rentType = 'null'!=op.rentType?op.rentType:''
		}
	}
</script>

<style lang="scss">
	.page {
		background-color: $grayf5;
	}

	.item {
		display: flex;
		flex-direction: column;
		background-color: white;
		border-radius: 8rpx;
		margin: 10rpx 20rpx;
		padding-bottom: 10rpx;
	}

	.title {
		width: 100%;
		height: 80rpx;
		line-height: 80rpx;
		font-size: 28rpx;
		color: $black33;
		margin-left: 20rpx;
	}

	.text-warn {
		font-size: 24rpx;
		color: $rede9;
		margin-right: 20rpx;
	}

	.text-warn-orange {
		color: $yellowffc;
	}

	.btn-detail {
		width: 180rpx;
		height: 60rpx;
		border-radius: 50rpx;
		color: white;
		text-align: center;
		background-color: $blue15;
		font-size: 26rpx;
		line-height: 60rpx;
		margin: 10rpx 20rpx 10rpx;
		align-self: flex-end;
	}
</style>
